/**************************************
 * File: GCInfo.h
 * Authors: Anders "Saasen" Stensaas
 *			Stig Magnus Halvorsen
 *			Peder Thorup
 * 
 * Description: Extracted from Osborne
 *				McGraw-Hill's gc.h
 *
 * Source:
 *	http://www.devarticles.com/c/a/Cplusplus/A-Simple-Garbage-Collector-for-C-plus-plus/3/
 *
 ************************************/

#ifndef GCINFO_H // inclusion guard
#define GCINFO_H

#include <list>

// This class defines an element that is stored
// in the garbage collection information list.

class GCInfo
{
public:
	// Constructor
	GCInfo(void *mPtr, unsigned size=0);

	// Overloading operator== allows GCInfos to be compared.
	// This is needed by the STL list class.
	bool operator==(const GCInfo &obj) const;

	unsigned refcount; // current reference count

	void *memPtr; // pointer to allocated memory

	// True if memPtr is pointing to array.
	bool isArray;

	// If memPtr is pointing to an allocated array,
	// then arraySize contains its size. If this is
	// an array, then size specifies the size of the array.
	unsigned arraySize;

	// gclist maintains the garbage collection list.
	static std::list<GCInfo> gclist;

	// true when first GCPtr is created
	static bool first;
};

#endif // end inclusion guard